// 引入数据库模块
var mysql      =  require('mysql');
//创建数据库链接
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '123456',
  database : 'user'
});
 
connection.connect();
//  查询
connection.query('SELECT * from user', function (error, results, fields) {
  if (error) throw error;
  console.log(results);
});